bool isValid(char* s) {
    int n=strlen(s);
    char stacks[10000]={0};
    int top=-1;
    int i;
    for(i=0;i<n;i++)
    {if (s[i]=='(' ||s[i]=='{'||s[i]=='[')
    {top++;
    stacks[top]=s[i];
    }
    else if (s[i]==')' ||s[i]=='}'||s[i]==']')
    {   if (top==-1)
       {return false;}
        if ((stacks[top]=='('&&s[i]==')')||(stacks[top]=='{'&&s[i]=='}')||(stacks[top]=='['&&s[i]==']'))
     top--;
     else return false;
    }}
    if (top==-1)
   { return true;}
    else return false;
}